
kmpkg_from_gitee(
        OUT_SOURCE_PATH SOURCE_PATH
        REPO kumose/faiss
        REF "v${VERSION}"
        SHA512 d32981afa6b7c35ae04f1c1e2b3dbd9651dddeff44225e645b0f94178b8fc6e54a0013efcd5a9c790bc88f69b44381a210aeadee52055e1e25c25b6f4e67ef70
        HEAD_REF master
)


kmpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
    FEATURES
        gpu FAISS_ENABLE_GPU
)

if ("${FAISS_ENABLE_GPU}")
    if (NOT KMPKG_CMAKE_SYSTEM_NAME AND NOT ENV{CUDACXX})
        set(ENV{CUDACXX} "$ENV{CUDA_PATH}/bin/nvcc.exe")
    endif()
endif()

kmpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    OPTIONS
        ${FEATURE_OPTIONS}
        -DFAISS_ENABLE_PYTHON=OFF  # Requires SWIG
        -DBUILD_TESTING=OFF
)

kmpkg_cmake_install()

kmpkg_cmake_config_fixup()

kmpkg_copy_pdbs()

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
